package com.avergel.metaserver.dao;

import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    private static Logger log = Logger.getLogger(HibernateUtil.class);
    static
    {
        try
        {
            sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
        } catch (Throwable ex) {
            // muestro el error
        	log.error("SessionFactory FALLO AL TRATAR DE INICIAR HIBERNATEUTIL \n" + ex);
			log.error(ex.getMessage());
			log.error(ex.getCause().getMessage());
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory()
    {
            return sessionFactory;           
    }
}